#ifndef _connector_h_
#define _connector_h_
#include"PlatformAPI.h"
#include"IMessageChannelFactory.h"
#include"IMessageSystem.h"
#include"Selector.h"
#include<string>

class Connector
{
public:
	Connector(Selector* pSelector,IMessageChannelFactory* pFactory);

	bool											Connect(const char* ip,unsigned int port,IMessageSystem::CallBack::OnConnectSuccess s,IMessageSystem::CallBack::OnConnectFail f,void* pTag);

	bool											Poll();

private:
	void											OnResult(bool bSuccess);

private:
	SOCKET											m_socket;
	Selector*										m_pSelector;
	IMessageSystem::CallBack::OnConnectSuccess		m_Success;
	IMessageSystem::CallBack::OnConnectFail			m_Fail;
	IMessageChannelFactory*							m_pFactory;
	std::string										m_ip;
	int												m_port;
	void* 											m_pTag;
};

#endif
